package com.itheima.object;

import java.io.*;

public class IODemo07  {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        readObject();
        //writeObject();


    }

    private static void writeObject() throws IOException {
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("c.txt"));
        User user=new User("zhangsan",19);
        oos.writeObject(user);
        oos.close();
    }

    private static void readObject() throws IOException, ClassNotFoundException {
        ObjectInputStream ois=new ObjectInputStream(new FileInputStream("c.txt"));
        User user = (User) ois.readObject();
        System.out.println(user);
        ois.close();
    }
}
